package com.qf.logistics.service.impl;

import com.qf.logistics.exceptions.MyBaseException;
import com.qf.logistics.exceptions.MyErrorCode;
import com.qf.logistics.mapper.MemberCarMapper;
import com.qf.logistics.pojo.MemberCar;
import com.qf.logistics.service.MemberCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import java.util.List;

/**
 * created by 赵文韬 on 2022/4/4 18:23
 */
@Service
@Transactional
public class MemberCarServiceImpl implements MemberCarService {
    private MemberCarMapper memberCarMapper;
    @Autowired
    public void setMemberCarMapper(MemberCarMapper memberCarMapper) {
        this.memberCarMapper = memberCarMapper;
    }

    @Override
    public List<MemberCar> findByMenberId(Long id) {
        //非空验证
        Assert.notNull(id,()->{
            throw new MyBaseException(MyErrorCode.PARAM_IS_NULL,"参数为空");
        } );
        //参数验证
        Assert.isTrue(id>0,()->{
            throw new MyBaseException(MyErrorCode.PARAM_IS_FAIL,"参数格式不正确" );
        } );
        return memberCarMapper.findByMemberId(id);
    }
}
